package com.cy.controller;

import com.cy.common.ResultResponse;
import com.cy.config.RequiresRole;
import com.cy.entity.SchoolInfo;
import com.cy.service.impl.SchoolInfoServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Aleven
 * @since 2024-12-21
 */
@RestController
@RequestMapping("/schoolinfo")
public class SchoolInfoController {
    @Autowired
    private SchoolInfoServiceImpl schoolInfoService;


    @Operation(summary = "分页查询所有学籍信息")
    @GetMapping("/selectPage")
    @RequiresRole("2")//仅管理员
    ResultResponse selectPage(@Param("page") Integer page, @Param("limit") Integer limit)throws Exception{
        return schoolInfoService.selectPage(page,limit);
    }
    @Operation(summary = "新增学籍信息")
    @PostMapping("/addInfo")
    @RequiresRole("2")//仅管理员
    ResultResponse addInfo(@RequestBody SchoolInfo schoolInfo)throws Exception{
        return schoolInfoService.addInfo(schoolInfo);
    }


    @Operation(summary = "修改学籍信息")
    @PutMapping("/updateInfo")
    @RequiresRole("2")//仅管理员
    ResultResponse updateInfo(@RequestBody SchoolInfo schoolInfo)throws Exception{
        return schoolInfoService.updateInfo(schoolInfo);
    }


    @Operation(summary = "删除学籍信息")
    @DeleteMapping("/deleteInfo")
    @RequiresRole("2")
    ResultResponse deleteInfo(@Param("Id") Integer Id)throws Exception{
        return schoolInfoService.deleteInfo(Id);
    }

}
